﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Threading;
using System.Net;
using System.IO;

namespace BackLib.Networking
{
    public class TCP
    {
        string ip;
        int port;
        bool host;
        public ITCPUser User;


        public TCP(bool host, string ip, int port)
        {
            this.host = host;
            this.ip = ip;
            this.port = port;
            Connect();
        }

        public void Connect()
        {
            if (host)
                User = new Server();
            else
                User = new Client(ip, port);
        }

        public void SendBytes(byte[] bytes)
        {
            User.SendData(bytes);
        }

        public void StartReading()
        {
            User.ReceiveData();
        }
    }
}
